Skip to content

Allow nested JSON structures in metadata#14

Merged
alex-feel merged 3 commits into
mainfrom
alex-feel-dev
Oct 10, 2025
Merged

Allow nested JSON structures in metadata#14
alex-feel merged 3 commits into
mainfrom
alex-feel-dev

Conversation

@alex-feel

Copy link
Copy Markdown
Owner

No description provided.

The MetadataDict type was overly restrictive, only allowing flat scalar values (dict[str, MetadataValue]). This prevented storing nested objects and arrays despite extensive documentation claiming these features were supported.

Changed MetadataDict from dict[str, MetadataValue] to dict[str, JsonValue], which supports recursive nested structures including objects, arrays, and mixed types. This aligns the implementation with documentation and enables all documented use cases.

Changes:
- app/types.py: Updated MetadataDict to use JsonValue for nested support
- app/models.py: Removed duplicate MetadataDict definition, import from types

Backward compatible: All existing flat metadata structures continue working.
Added extensive test coverage for nested JSON structures in metadata to validate the fix allowing nested objects and arrays. Tests cover:
- Deeply nested objects (3-4 levels)
- Arrays with mixed types
- Nested path queries with dot notation
- Complex real-world scenarios
- Metadata preservation across store/retrieve cycles

All tests verify that nested structures are correctly stored, retrieved, and queryable as documented.
Added 5 comprehensive integration tests validating nested JSON support:
- Complex nested objects (4 levels deep)
- Array storage with mixed types
- Deep nesting validation (7 levels)
- Mixed nested structures (objects + arrays)
- Backward compatibility with flat metadata

All tests use proper pytest fixtures and async patterns. Tests verify that nested structures are correctly stored, retrieved, and preserved through the full storage lifecycle.
@github-actions

Copy link
Copy Markdown

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  app
  models.py
  types.py
Project Total  

This report was generated by python-coverage-comment-action

@alex-feel alex-feel merged commit 683b725 into main Oct 10, 2025
6 checks passed
@alex-feel alex-feel deleted the alex-feel-dev branch October 10, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant